package com.student.service;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.student.dao.HistoryDao;
import com.student.model.History;
import com.student.model.OperateType;
import com.student.model.UserType;
import com.student.util.PageInfo;

@Component("HistoryService")
public class HistoryService {
	
	private HistoryDao historyDao;
	public HistoryDao getHistoryDao() {
		return historyDao;
	}
	@Resource(name="HistoryDao")
	public void setHistoryDao(HistoryDao historyDao) {
		this.historyDao = historyDao;
	}
	
	public void addHistory(Long userId, String operateType, Long studentId,
			Timestamp operateTime, String description) throws Exception{
		

		try {
			historyDao.addHistory(userId, operateType, studentId, operateTime, description);
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e);
		}

	}

	public List<History> gainHistory(String [] operateType, Long collegeId, Long userId,String userRole,PageInfo pageInfo)
			throws Exception {
		try {
			return historyDao.gainHistory(operateType, collegeId, userId, userRole,pageInfo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e);
		}
	}
	public List<OperateType> getAllOperateType() throws Exception {
		try {
			
			return this.historyDao.getAllOperateType();
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e);
		}
	}

	public List<UserType> getAllUserType() throws Exception {
		
		try {
			
			return this.historyDao.getAllUserType();
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e);
		}
	}
}
